var value = false;
	
$(document).ready(function () {
	
	$( "input:button, input:submit" ).button();
	$( "#radio" ).buttonset();
	// 初始化
	init();
	
	// 添加键盘事件
  	$('#awb').keydown(function(event) {
  		var num = Number($('#awb').val());
  		var keycode = event.which;
  		
  		if((keycode >=48 && keycode <= 57) || (keycode >=96 && keycode <= 105)) {
  		} else if(keycode == 38 || keycode == 39){
  			$('#awb').attr('value', num + 1);
  		} else if(keycode == 37 || keycode == 40){
  			$('#awb').attr('value', num - 1);
  		} else if(keycode >= 65 && keycode <= 90) {
  			event.returnvalue = false
  		}
	});
	
	bindKeyCloseWin();
	
	$('#serial').keydown(function(event) {
  		var num = Number($('#serial').val());
  		var keycode = event.which;
  		
  		if((keycode >=48 && keycode <= 57) || (keycode >=96 && keycode <= 105)) {
  		} else if(keycode == 38 || keycode == 39){
  			$('#serial').attr('value', num + 1);
  		} else if(keycode == 37 || keycode == 40){
  			$('#serial').attr('value', num - 1);
  		} else if(keycode >= 65 && keycode <= 90) {
  			event.returnvalue = false
  		}
	});
});

function init() {
	$('#print_flag').attr('value', false);
	$('#send_goods_flag').attr('value', false);
	
	// 设置默认的运单号
	setAWB();
}

function printKD(tid) {
	tid = tid.split(',')[0];
	
	$.get("./servlet/PrintExpress", { tid: tid, print_flag: true});
}

function sendGoods() {
	$('#send_goods_flag').attr('value', true);
	confirms('你确定要发货吗(点了发货就不能更改了哦!!!!)?');
}

function printAndSendGoods() {
	$('#send_goods_flag').attr('value', true);
	$('#print_flag').attr('value', true);
	confirms('你确定要发货并且打印吗(点了发货就不能更改了哦!!!!)?');
}

function showAwbDescript() {
	var html = "<font size='2' color='red'>按上下键可以递增或者递减</font>";
	$("#awb_desc").html(html);
}

function confirms(str) {
	var form = $('#form');
	var xx = window.confirm(str);
	if(!xx) {
		form.attr('action', '#');
	} else {
		value = true;
		form.submit();
	}
}

function setAWB() {
	var express = $("#express").val();
	$.get("awb.jsp", { express: express }, function(data) {
		$("#awb").attr("value", data);
	});
}

function selecChange() {   	 		
	setAWB();
}

function test() {
	var str = 'nihk';
	alert(str.match('nihk')); 	 		
}